package cn.knightzz.controller;


import cn.knightzz.entity.JsonResult;
import cn.knightzz.entity.SysMessage;
import cn.knightzz.service.SysUserMessageService;
import org.apache.http.cookie.SM;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author knightzz
 * @since 2021-05-07
 */
@RestController
public class SysUserMessageController {

    @Resource
    SysUserMessageService userMessageService;

    @GetMapping("/messages/user/{id}")
    public JsonResult<List<SysMessage>> getMessageByUserId(@PathVariable Long id) {
        List<SysMessage> messageList = userMessageService.getMessageByUserId(id);
        JsonResult<List<SysMessage>> result = new JsonResult<>("200", "消息列表获取成功");
        result.setData(messageList);
        return result;
    }
}

